import React from 'react';
import { Table, Icon } from 'antd';

let List = React.createClass({
    getDetail(params){
        
        this.props.getDetail(params);
    },
    handleTableChange(pagination){
    
        const pager = this.props.pagination;
        pager.current = pagination.current;
        pager.currentPage = pagination.current;
       
        this.props.getPagination('1',pager)
    },
    rowKey(data){
        return data.id;
    },
    render() {
        const columns = [
            {
                title: '房源地址',
                dataIndex: 'address',
                key: 'address',
            },
            {
                title: '融资起止时间',
                dataIndex: 'time',
                key: 'time',
                render: (text, record) => <span>{record.startTime}&nbsp;至&nbsp;{record.endTime}</span>,
            },
            {
                title: '融资类型',
                dataIndex: 'type',
                key: 'type',
                render: (text, record) => {
                    const financeType = {
                        '101': '收房贷',
                        '102': '装修贷',
                        '103': '租约贷'
                    }
                    return (
                        <span>{financeType[record.type]}</span>
                    )
                }
            },
            {
                title: '融资总金额(元)',
                dataIndex: 'amount',
                key: 'amount',
            },
            {
                title: '年利率(%)',
                dataIndex: 'interestRate',
                key: 'interestRate',
            },
            {
                title: '操作',
                dataIndex: 'more',
                key: 'more',
                render: (text,record) => {
                    let params = {
                        financeId: record.id,                        
                    }
                    return (
                        <a href="javascript:;" onClick={this.getDetail.bind(this, params )}>详情</a>
                    )
                }
            },
            
        ];

        return (
            <Table rowKey={this.rowKey}
             columns={columns} 
             dataSource={this.props.dataList} 
             pagination={this.props.pagination}
             onChange={this.handleTableChange}/>
        )
    }
});

export default List